<template>
  <div class="wechat-record">
    <c-title :hide="false" :text="new_wx_transfer_page_name"></c-title>
    <div class="listBox">
      <div class="lis" v-for="(item, index) in list" :key="index">
        <div class="lis_top">
          <div class="lis_top_l">提现至微信</div>
          <div class="lis_top_r">{{ $i18n.t("money") }}{{ item.love_value }}</div>
        </div>
        <div class="lis_bottom">{{ item.created_at }}</div>
        <div class="btnBox">
          <div class="btn" v-if="item.status == 1 || item.status == 4" @click="toWechat(item)">确认收款</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { scrollMixin } from "../../../utils/mixin";
export default {
  mixins: [scrollMixin], //加载更多
  data() {
    return {
      page: 1,
      total_page: 0,
      isLoadMore: false,

      list: [],
      new_wx_transfer_page_name: "提现到微信确认收款"
    };
  },
  activated() {
    this.init();
    this.getData();
  },
  methods: {
    toWechat(item) {
      console.log(item.withdraw_sn, "爱心值提现单号,爱心值确认收款页传这个");
      this.$router.push(this.fun.getUrl("wechatWithdrawal", { id: item.withdraw_sn, orderType: "love" }));
    },
    init() {
      this.page = 1;
      this.total_page = 0;
      this.list = [];
    },
    async getData() {
      let { data, msg, result } = await $http.post("plugin.love.Frontend.Modules.Love.Controllers.wx-transfer.index", {}, "");
      if (result) {
        this.list = data.data;
        this.total_page = data.last_page;
        this.isLoadMore = true;
        this.new_wx_transfer_page_name = data.new_wx_transfer_page_name;
      } else {
        this.$toast(msg);
      }
    },
    async getMoreData() {
      if (!this.isLoadMore) return;
      this.isLoadMore = false;
      if (this.page >= this.total_page) {
        return;
      } else {
        this.page += 1;
        let { data, msg, result } = await $http.post("plugin.love.Frontend.Modules.Love.Controllers.wx-transfer.index", {}, "");
        if (result) {
          this.list = this.list.concat(data.data);
        } else {
          this.page = this.page - 1;
          this.isLoadMore = true;
          this.$toast(msg);
        }
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.listBox {
  margin: 0 0.75rem;
  margin-top: 0.75rem;
  box-sizing: border-box;
  .lis {
    display: flex;
    flex-direction: column;
    background: #fff;
    padding: 0.64rem;
    border-radius: 0.325rem;
    box-sizing: border-box;
    margin-bottom: 0.5rem;
    .lis_top {
      display: flex;
      justify-content: space-between;
      .lis_top_r {
        color: red;
      }
    }
    .lis_bottom {
      text-align: left;
      font-size: 0.8rem;
      color: #999;
      margin-top: 0.3rem;
    }
    .btnBox {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      color: #fff;
      .btn {
        background: #ef5452;
        padding: 0.35rem 0.5rem;
        box-sizing: border-box;
        border-radius: 0.78rem;
      }
    }
  }
}
</style>
